import os

if __name__ == '__main__':

    with open('./ljs_audio_text_test_filelist.txt.cleaned', 'r') as f:
        texts = f.readlines()
    texts_64 = []
    texts_128 = []
    texts_256 = []
    texts_384 = []

    for t in texts:
        prefix, content = t.split('|')[:]
        # print(prefix, content)
        if 2 * len(content) <= 64:
            texts_64.append(t)
        elif 2 * len(content) <= 128:
            texts_128.append(t)
        elif 2 * len(content) <= 256:
            texts_256.append(t)
        elif 2 * len(content) <= 384:
            texts_384.append(t)
        else:
            assert 1 == 0
    with open('./ljs_audio_text_test_64_filelist.txt.cleaned', 'w') as f:
        f.writelines(texts_64)
    with open('./ljs_audio_text_test_128_filelist.txt.cleaned', 'w') as f:
        f.writelines(texts_128)
    with open('./ljs_audio_text_test_256_filelist.txt.cleaned', 'w') as f:
        f.writelines(texts_256)
    with open('./ljs_audio_text_test_384_filelist.txt.cleaned', 'w') as f:
        f.writelines(texts_384)
